<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>业务域名设置</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
  {include file="public/css"/}
	<style>
		.labelValue {line-height: 20px;
			padding: 9px 15px;
			word-wrap: break-word;
		}
	</style>
</head>
<body>
  <div class="layui-fluid">
    <div class="layui-row layui-col-space15">
      <div class="layui-card layui-col-md12">
		<div class="layui-card-header"><i class="fa fa-cog"></i> 业务域名设置<i class="layui-icon layui-icon-close" style="font-size:18px;font-weight:bold;cursor:pointer" onclick="closeself()"></i></div>
		<div class="layui-card-body" pad15>
			<blockquote class="layui-elem-quote" style="color:#333">
				1.先下载域名校验文件放入要配置的域名根目录（文件名一模一样不能修改），配置提交后，需重新提交代码审核，审核通过且重新发布上线后才会生效。<br>
				2.提交后还未重新发布上线前，再次打开看不到上次的配置为正常情况，上次的配置还未生效，接口读取的是已生效的配置，审核通过且重新发布上线后才会生效。<br>
				3.业务域名需经过ICP备案，新备案域名需24小时后才可配置。域名格式只支持英文大小写字母、数字及“-”，不支持IP地址。<br>
				4.<a href="https://developers.weixin.qq.com/miniprogram/dev/framework/ability/domain.html" target="_blank">官方域名配置说明文档</a>
			</blockquote>
			<div class="layui-form form-label-w10" lay-filter="">
				<div class="layui-form-item">
					<label class="layui-form-label">域名校验文件：</label>
					<div class="layui-col-md8">{$confirmFileName} <button class="table-btn" data-url = "{$confirmFile}" data-name = "{$confirmFileName}" onclick="download(this)" >域名校验文件下载</button></div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label">业务域名：</label>
					<div class="layui-col-md8">
						<input type="text" name="info[webviewdomain]" value="{$info['webviewdomain']}" class="layui-input" lay-verify="required" lay-verType="tips"/>
					</div>
					<div class="layui-form-mid layui-word-aux layui-clear">以 https:// 开头。可填写300个域名，域名间请用英文 ; 分割</div>
				</div>
				<div class="layui-form-item">
					<label class="layui-form-label"></label>
					<div class="layui-input-block">
						<button class="layui-btn layui-btn-primary" onclick="getEffectiveJumpDomain()">查看发布后生效域名</button><button class="layui-btn" lay-submit lay-filter="formsubmit">提 交</button>
					</div>
				</div>
			</div>
		</div>
      </div>
    </div>
  </div>
	{include file="public/js"/}
	<script>
	layui.form.on('submit(formsubmit)', function(obj){
		var field = obj.field
		$.post('',field,function(data){
			dialog(data.msg,data.status,data.url);
		})
	})
	function getEffectiveJumpDomain(){
		var index = layer.load();
		$.get("{:url('getEffectiveJumpDomain')}",{},function(res){
			layer.close(index);
			var data = res.data;
			if(res.status != 1){
				dialog(res.msg,res.status);return;
			}

			var html = '<div style="margin:auto auto;">';
			html+='<div class="layui-form form-label-w10" lay-filter="">\n' +
					'\t\t\t\t<div class="layui-form-item">\n' +
					'\t\t\t\t\t<label class="layui-form-label">业务域名：</label>\n' +
					'\t\t\t\t\t<div class="layui-col-md8 labelValue">\n' +
					data.webviewdomain +
					'\t\t\t\t\t</div>\n' +
					'\t\t\t\t</div>'+
				'</div>';
			html+='</div>'

			layer.open({type:1,area:['740px','320px'],content:html,title:'发布后生效域名',shadeClose:true})
		});
	}
	// 下载
	function download(obj){
		var url= $(obj).data('url');
		var name= $(obj).data('name');
		// 创建一个a标签
		var a = document.createElement("a");
		// 设置a标签的href属性
		a.href = url;
		a.target = "_bank";
		// 设置a标签的download属性
		a.download = name;
		// 触发a标签的点击事件
		a.click();
		// 移除a标签
		a.remove();
	}
  </script>
	{include file="public/copyright"/}
</body>
</html>